// SISTEMA : Sistema de Identificacao Criminal
// PROGRAMA : SCRP001
// O QUE FAZ � Alteracao da Ficha Indice Criminal
// Data : 29 de Julho de 1997
package br.com.vti.sisp_sicrim.antigo.controller.programa;

import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Result;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrm2000;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrm2100;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrm2200;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrm2300;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrp1200A;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrp1200B;
import br.com.vti.sisp_sicrim.antigo.controller.tela.Scrp1200C;
import br.com.vti.sisp_sicrim.antigo.model.SicCadastro;
import br.com.vti.sisp_sicrim.antigo.model.SicNumero;
import br.com.vti.sisp_sicrim.antigo.util.ExceptionProgram;
import br.com.vti.sisp_sicrim.antigo.util.Scrg001;
import br.com.vti.sisp_sicrim.antigo.util.Sessao;
import br.com.vti.sisp_sicrim.antigo.util.UtilBean;

/**
 * Classe : Scrp1200 O QUE FAZ � Alteracao da Ficha Indice Criminal *
 * 
 * @author Incode - Data: mai/2014
 * 
 */

public class Scrp1200 {
	// Views utilizadas
	SicCadastro criminalView = new SicCadastro();
	SicNumero numeroView = new SicNumero();
	// Telas/relatorios utilizados
	Scrm2000 scrm2000;
	Scrm2100 scrm2100;
	Scrm2200 scrm2200;
	Scrm2300 scrm2300;
	Scrp1200A scrp1200A;
	Scrp1200B scrp1200B;
	Scrp1200C scrp1200C;
	// Includes utilizados
	// Areas globais / session
	Scrg001 scrg001;
	// Funcoes/subrotinas
	FuncoesGerais funcoes = new FuncoesGerais();
	Scrp1200 scrp1200;
	Result result;
	Sessao sessao;
	Boolean primeiraVez = false;
	Scrp1200 scrp1200Anterior;
	String faseproc = "0";
	String mensagemInicial = "";

	private String jEmpresa = "PRODAMAR";
	private String jProgram = this.getClass().getSimpleName();
	private String jFuncao = "ALTERACAO";
	// private String chave = "A";
	private String dmanas = "";
	private long jUltNum = 0;
	private String jMaeLimpa = "";
	private String jCrime = "";

	private Scrm2000 preMapas() {
		scrm2000 = new Scrm2000(true, sessao);
		scrm2100 = new Scrm2100(true, sessao);
		scrm2300 = new Scrm2300(true, sessao);
		scrp1200A = new Scrp1200A(true, sessao);
		scrp1200B = new Scrp1200B(true, sessao);
		scrp1200C = new Scrp1200C(true, sessao);
		sessao.getScrg001().setWContadorw(0);

		sessao.getScrg001().setWProgramaw(this.getClass().getSimpleName());
		criminalView.wFunc = "ALTERACAO";

		// Par�grafo: rp1()
		return scrm2000;
	}

	public Scrp1200(Result result, Sessao sessao) {
		this.result = result;
		this.sessao = sessao;
	}

	@Post
	public void executar(Scrm2000 scrm2000, Scrm2100 scrm2100, Scrm2200 pscrm2200, Scrm2300 scrm2300, Scrp1200A scrp1200A, Scrp1200B scrp1200B, Scrp1200C scrp1200C) {
		try {
			main(scrm2000, scrm2100, scrm2200, scrm2300, scrp1200A, scrp1200B, scrp1200C);
		} catch (Exception e) {
			ExceptionProgram excp = new ExceptionProgram();
			excp.trataErroScrcerro(e, sessao, this.getClass().getSimpleName());
		}
	}

	private void main(Scrm2000 pscrm2000, Scrm2100 pscrm2100, Scrm2200 pscrm2200, Scrm2300 pscrm2300, Scrp1200A pscrp1200A, Scrp1200B pscrp1200B, Scrp1200C pscrp1200C) throws Exception {
		if (pscrm2000 == null && pscrm2100 == null && pscrm2200 == null && pscrm2300 == null && pscrp1200A == null && pscrp1200B == null && pscrp1200C == null) {
			primeiraVez = true;
			// scrm2000 = new Scrm2000 (primeiraVez);
			scrm2000 = preMapas();
			scrm2000.setNavegar("../scrp1200/executar");
			scrm2000.setMensagem(mensagemInicial);
			result.include("scrm2000", scrm2000);
			sessao.setAtributo("SCRP1200", this);
			scrm2000.enviarTela(primeiraVez, result, getClass().getSimpleName().toUpperCase());
			return;
		} else {
			restaurarEstados(pscrm2000, pscrm2100, pscrm2200, pscrm2300, pscrp1200A, pscrp1200B, pscrp1200C);
		}
		// Repeat
		scrp1200 = new Scrp1200(result, sessao);
		sessao.getScrg001().setWVltw(2);
		criminalView.wChv = "*";
		criminalView.wLoop += 1;
		scrm2300.setJocorrencia(1);

		if (pscrm2000 != null) {
			scrm2000.receberTela(false, result);
		}
		// Par�grafo: fd33()
		criminalView.consultaRegEstadualGeral(scrm2000.getJregGeral());
		if (criminalView.registrosProcessados() > 0)
		// && S-MAOESQ = criminalView.wMAO-ESQUERDA)
		{
			if (criminalView.getStatusReg() == 5) {
				scrm2000.enviarMensagem(null, "Esta ficha esta� excluida - Nao pode ser alterada");
				return;
			}

			criminalView.wData_nasc0 = String.valueOf(criminalView.getDataNasc());

			criminalView.wData_nasc0 = UtilBean.subStr(criminalView.wData_nasc0, 4, 4) + UtilBean.subStr(criminalView.wData_nasc0, 2, 2) + UtilBean.subStr(criminalView.wData_nasc0, 0, 2);

			criminalView.wDataRegistro0 = criminalView.getDataReg();
			criminalView.wDataRegistro0 = (int) UtilBean.extraiDigitos(criminalView.wDataRegistro, 8, 5, 4) * 10000 + (int) UtilBean.extraiDigitos(criminalView.wDataRegistro, 8, 3, 2) * 100 + (int) UtilBean.extraiDigitos(criminalView.wDataRegistro, 8, 1, 2);

			scrm2000.setJregGeral(criminalView.getRegEstadualGeral());
			criminalView.wIdentidade = criminalView.getRegFederalCi();

			criminalView.wStatus0 = criminalView.getStatusReg();

			scrm2100.setJnomecompleto(criminalView.getNomeCompleto());
			criminalView.wPai = criminalView.getNomePai();

			scrm2100.setJmae(criminalView.getNomeMae());
			scrm2100.setDedos(1, 1, criminalView.getPolegarDireito());
			scrm2100.setDedos(2, 1, criminalView.getIndicadorDireito());
			scrm2100.setDedos(3, 1, criminalView.getMedioDireito());
			scrm2100.setDedos(4, 1, criminalView.getAnularDireito());
			scrm2100.setDedos(5, 1, criminalView.getMinimoDireito());
			scrm2100.setDedos(1, 2, criminalView.getPolegarEsquerdo());
			scrm2100.setDedos(2, 2, criminalView.getIndicadorEsquerdo());
			scrm2100.setDedos(3, 2, criminalView.getMedioEsquerdo());
			scrm2100.setDedos(4, 2, criminalView.getAnularEsquerdo());
			scrm2100.setDedos(5, 2, criminalView.getMinimoEsquerdo());
			criminalView.wDelegacia = criminalView.getNomeDelegacia();

			criminalView.wDescMunicipio = criminalView.getMunicipioRegGeral();
			criminalView.wMunicipio = criminalView.getCodigoMunicipioRegGeral();
			criminalView.wUfRegGeral = criminalView.getUfRegEstadualGeral();
			criminalView.wNoAutos = criminalView.getNumeroAutos();
			criminalView.wDataAtuacao = criminalView.getDataAtuacao();
			criminalView.wNomeAnterior = criminalView.getNomeAnterior();
			criminalView.wAlcunha = criminalView.getApelidoAlcunhas();
			criminalView.wSexo = criminalView.getSexo();
			criminalView.wNaturalidade = criminalView.getNaturalidade();
			criminalView.wCodMunNascimento = criminalView.getCodigoMunicipioNasc();
			criminalView.wUfNascimento = criminalView.getUfNaturalidade();
			criminalView.wDocApresentado = criminalView.getDocumentoApresent();
			criminalView.wNumDocApresentado = criminalView.getNumDocumentoApresent();
			criminalView.wOrgaoExpUf = criminalView.getOrgaoExpUfUfUf();
			criminalView.wProfissao = criminalView.getProfissao();
			criminalView.wInstrucao = criminalView.getGrauInstrucao();
			criminalView.wAvRua = criminalView.getAvRua();
			criminalView.wNumero = criminalView.getNumero();
			criminalView.wBairro = criminalView.getBairro();
			criminalView.wMunEndereco = criminalView.getMunicipio();
			criminalView.wUfEndereco = criminalView.getEstado();
			criminalView.wCep = criminalView.getCep();
			criminalView.wComplemento = criminalView.getComplemento();
			criminalView.wAltura0 = criminalView.getAltura();
			criminalView.wEstadoCivil0 = criminalView.getEstadoCivil();
			criminalView.wCutis0 = criminalView.getCodigoCutis();
			criminalView.wCorCabelo0 = criminalView.getCodigoCorCabelo();
			criminalView.wTipoCabelo0 = criminalView.getCodigoTipoCabelo();
			criminalView.wCorOlhos0 = criminalView.getCodigoCorOlhos();
			scrm2300.setJsinais(criminalView.getMarcaPartCicatTatuag());
			criminalView.wCompleicao0 = criminalView.getCompleicao();

			scrm2300.setJnomevitima(criminalView.getNomeVitima());
			scrm2300.setJmotivo(criminalView.getMotivoPrisaoLei());
			criminalView.wObservacoez = criminalView.getObservacao();
			scrm2300.setJobservacoes(1, criminalView.wObservacoez[1]);
			scrm2300.setJobservacoes(2, criminalView.wObservacoez[2]);
			scrm2300.setJobservacoes(3, criminalView.wObservacoez[3]);
			scrm2300.setJobservacoes(4, criminalView.wObservacoez[4]);
			verStatus();

			if (pscrm2000 != null && pscrm2100 == null && pscrm2200 == null && pscrm2300 == null && pscrp1200A == null && pscrp1200B == null && pscrp1200C == null) {
				result.include("scrm2100", scrm2100);
				sessao.setAtributo("SCRP1200", this);
				scrm2100.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
				return;
			}
			if (pscrm2100 != null) {
				scrm2100.receberTela(false, result);
			}
			if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {
				scrp1200.executar(null, null, null, null, null, null, null);
				return;
			}

			criminalView.wData_nasc = dmanas;

			criminalView.wMaoDireita = UtilBean.moveSubstring(criminalView.wMaoDireita, 0, 7, "A", scrm2100.getDedos(1, 1));
			criminalView.wMaoDireita = UtilBean.moveSubstring(criminalView.wMaoDireita, 7, 7, "A", scrm2100.getDedos(2, 1));
			criminalView.wMaoDireita = UtilBean.moveSubstring(criminalView.wMaoDireita, 14, 7, "A", scrm2100.getDedos(3, 1));
			criminalView.wMaoDireita = UtilBean.moveSubstring(criminalView.wMaoDireita, 21, 7, "A", scrm2100.getDedos(4, 1));
			criminalView.wMaoDireita = UtilBean.moveSubstring(criminalView.wMaoDireita, 28, 7, "A", scrm2100.getDedos(5, 1));

			criminalView.wMaoEsquerda = UtilBean.moveSubstring(criminalView.wMaoEsquerda, 0, 7, "A", scrm2100.getDedos(1, 2));
			criminalView.wMaoEsquerda = UtilBean.moveSubstring(criminalView.wMaoEsquerda, 7, 7, "A", scrm2100.getDedos(2, 2));
			criminalView.wMaoEsquerda = UtilBean.moveSubstring(criminalView.wMaoEsquerda, 14, 7, "A", scrm2100.getDedos(3, 2));
			criminalView.wMaoEsquerda = UtilBean.moveSubstring(criminalView.wMaoEsquerda, 21, 7, "A", scrm2100.getDedos(4, 2));
			criminalView.wMaoEsquerda = UtilBean.moveSubstring(criminalView.wMaoEsquerda, 28, 7, "A", scrm2100.getDedos(5, 2));

			// Par�grafo: fd34()
			criminalView.consultaMaoDireitaMaoEsquerda(
			// jMaoDireita,
			scrm2100.getDedos(1, 1), scrm2100.getDedos(2, 1), scrm2100.getDedos(3, 1), scrm2100.getDedos(4, 1), scrm2100.getDedos(5, 1),
			// jMaoEsquerda
			scrm2100.getDedos(1, 2), scrm2100.getDedos(2, 2), scrm2100.getDedos(3, 2), scrm2100.getDedos(4, 2), scrm2100.getDedos(5, 2));
			if (criminalView.getRegEstadualGeral() != scrm2100.getJregGeral()) {
				if (jCrime.trim().equals("")) {
					jCrime = "*";
					scrm2100.enviarMensagem(null, "Formula Datil. Ja�Cadastrada Anteriormente.Consulte-a ou- Tecle <ENTER> p/ Cont.");
					return;
				}
			}

			if (pscrm2000 == null && pscrm2100 != null && pscrm2200 == null && pscrm2300 == null && pscrp1200A == null && pscrp1200B == null && pscrp1200C == null) {
				result.include("scrm2200", scrm2200);
				sessao.setAtributo("SCRP1200", this);
				scrm2200.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
				return;
			}
			if (pscrm2200 != null) {
				scrm2200.receberTela(false, result);
			}
			if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {
				return;
			}

			if (pscrm2000 == null && pscrm2100 == null && pscrm2200 != null && pscrm2300 == null && pscrp1200A == null && pscrp1200B == null && pscrp1200C == null) {
				result.include("scrm2300", scrm2300);
				sessao.setAtributo("SCRP1200", this);
				scrm2300.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
				return;
			}
			if (pscrm2300 != null) {
				scrm2300.receberTela(false, result);
			}
			if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {
				scrp1200.executar(null, null, null, null, null, null, null);
				return;
			}

			criminalView.wData_atu = UtilBean.obtemDataCorrente();
			//

			criminalView.wHora = Integer.parseInt(UtilBean.subStr(criminalView.wTempo, 0, 2));
			criminalView.wMin = Integer.parseInt(UtilBean.subStr(criminalView.wTempo, 3, 2));
			criminalView.wSeg = Integer.parseInt(UtilBean.subStr(criminalView.wTempo, 6, 2));
			criminalView.wNse = Integer.parseInt(UtilBean.subStr(criminalView.wTempo, 9, 1));

			criminalView.wData_nasc0 = String.valueOf(criminalView.getDataNasc());
			criminalView.wDataRegistro0 = criminalView.getDataReg();

			criminalView.wData_nasc = UtilBean.subStr(criminalView.wData_nasc0, 4, 4) + UtilBean.subStr(criminalView.wData_nasc0, 2, 2) + UtilBean.subStr(criminalView.wData_nasc0, 0, 2);

			criminalView.wDataRegistro = (int) UtilBean.extraiDigitos(criminalView.wDataRegistro0, 8, 5, 4) * 10000 + (int) UtilBean.extraiDigitos(criminalView.wDataRegistro0, 8, 3, 2) * 100 + (int) UtilBean.extraiDigitos(criminalView.wDataRegistro0, 8, 1, 2);

			if (scrm2300.getJobservacoes(1).trim().equals("")) {
				if (criminalView.wChv.equals("*")) {
					criminalView.wChv = "";
					scrm2300.enviarMensagem(null, "Nenhuma ocorrencia foi informada.Se nao quiser- informar Tecle<ENTER>p/confirmar");
					return;
				}
			}
			gravaOcorrencias(pscrp1200A);
			if (scrm2100.getJmae().equals("*") || scrm2100.getJmae().trim().equals("")) {
				scrm2100.setJmae("************");
			}
			if (criminalView.wPai.equals("*") || criminalView.wPai.trim().equals("")) {
				criminalView.wPai = "************";
			}
			if (criminalView.wAlcunha[1].trim().equals("") || criminalView.wAlcunha.equals("*")) {
				criminalView.wAlcunha[1] = "************";
			}
			if (criminalView.wNomeAnterior.trim().equals("") || criminalView.wNomeAnterior.equals("*")) {
				criminalView.wNomeAnterior = "************";
			}
			if (criminalView.wNaturalidade.equals("*")) {
				criminalView.wNaturalidade = "************";
			}
			if (criminalView.wDocApresentado.equals("*")) {
				criminalView.wDocApresentado = "************";
			}
			if (criminalView.wAvRua.equals("*")) {
				criminalView.wAvRua = "************";
			}
			if (criminalView.wBairro.equals("*")) {
				criminalView.wBairro = "************";
			}
			if (criminalView.wComplemento.trim().equals("") || criminalView.wComplemento.equals("*")) {
				criminalView.wComplemento = "************";
			}
			if (scrm2300.getJsinais().equals("*")) {
				scrm2300.setJsinais("************");
			}
			if (scrm2300.getJnomevitima().equals("*")) {
				scrm2300.setJnomevitima("************");
			}
			if (criminalView.wDataAtuacao < 1) {
				criminalView.wDataAtuacao = 0;
			}
			if (criminalView.wNoAutos < 1) {
				criminalView.wNoAutos = 0;
			}
			if (criminalView.wNumero < 1) {
				criminalView.wNumero = 0;
			}
			if (criminalView.wNumDocApresentado < 1) {
				criminalView.wNumDocApresentado = 0;
			}
			if (criminalView.wCodMunNascimento < 1) {
				criminalView.wCodMunNascimento = 0;
			}
			if (criminalView.wUfNascimento.trim().equals("")) {
				criminalView.wUfNascimento = "**";
			}
			if (criminalView.wCep < 1) {
				criminalView.wCep = 0;
			}
			if (criminalView.wMunEndereco < 1) {
				criminalView.wMunEndereco = 0;
			}
			if (criminalView.wUfEndereco.trim().equals("")) {
				criminalView.wUfEndereco = "**";
			}
			if (criminalView.wProfissao.equals("*") || criminalView.wProfissao.trim().equals("")) {
				criminalView.wProfissao = "************";
			}
			if (criminalView.wOrgaoExpUf.equals("*") || criminalView.wOrgaoExpUf.trim().equals("")) {
				criminalView.wOrgaoExpUf = "************";
			}
			criminalView.setObservacao(criminalView.wObservacoez);
			criminalView.setRegEstadualGeral(scrm2000.getJregGeral());
			criminalView.setRegFederalCi(criminalView.wIdentidade);
			criminalView.setStatusReg(criminalView.wStatus0);
			criminalView.setTipoReg("AL");
			criminalView.setNomeCompleto(scrm2100.getJnomecompleto());
			criminalView.setNomePai(criminalView.wPai);
			criminalView.setNomeMae(scrm2100.getJmae());
			criminalView.setDataNasc(criminalView.wData_nasc00);
			criminalView.setPolegarDireito(scrm2100.getDedos(1, 1));
			criminalView.setIndicadorDireito(scrm2100.getDedos(2, 1));
			criminalView.setMedioDireito(scrm2100.getDedos(3, 1));
			criminalView.setAnularDireito(scrm2100.getDedos(4, 1));
			criminalView.setMinimoDireito(scrm2100.getDedos(5, 1));
			criminalView.setPolegarEsquerdo(scrm2100.getDedos(1, 2));
			criminalView.setIndicadorEsquerdo(scrm2100.getDedos(2, 2));
			criminalView.setMedioEsquerdo(scrm2100.getDedos(3, 2));
			criminalView.setAnularEsquerdo(scrm2100.getDedos(4, 2));
			criminalView.setMinimoEsquerdo(scrm2100.getDedos(5, 2));
			criminalView.setNomeDelegacia(criminalView.wDelegacia);
			criminalView.setMunicipioRegGeral(criminalView.wDescMunicipio);
			criminalView.setCodigoMunicipioRegGeral(criminalView.wMunicipio);
			criminalView.setUfRegEstadualGeral(criminalView.wUfRegGeral);
			criminalView.setDataReg(criminalView.wDataRegistro0);
			criminalView.setNumeroAutos(criminalView.wNoAutos);
			criminalView.setDataAtuacao(criminalView.wDataAtuacao);
			criminalView.setNomeAnterior(criminalView.wNomeAnterior);
			criminalView.setApelidoAlcunhas(criminalView.wAlcunha);
			criminalView.setSexo(criminalView.wSexo);
			criminalView.setNaturalidade(criminalView.wNaturalidade);
			criminalView.setCodigoMunicipioNasc(criminalView.wCodMunNascimento);
			criminalView.setUfNaturalidade(criminalView.wUfNascimento);
			criminalView.setDocumentoApresent(criminalView.wDocApresentado);
			criminalView.setNumDocumentoApresent(criminalView.wNumDocApresentado);
			criminalView.setOrgaoExpUfUfUf(criminalView.wOrgaoExpUf);
			criminalView.setProfissao(criminalView.wProfissao);
			criminalView.setGrauInstrucao(criminalView.wInstrucao);
			criminalView.setAvRua(criminalView.wAvRua);
			criminalView.setNumero(criminalView.wNumero);
			criminalView.setBairro(criminalView.wBairro);
			criminalView.setMunicipio(criminalView.wMunEndereco);
			criminalView.setEstado(criminalView.wUfEndereco);
			criminalView.setCep(criminalView.wCep);
			criminalView.setComplemento(criminalView.wComplemento);
			criminalView.setAltura(criminalView.wAltura0);
			criminalView.setEstadoCivil(criminalView.wEstadoCivil0);
			criminalView.setCodigoCutis(criminalView.wCutis0);
			criminalView.setCodigoCorCabelo(criminalView.wCorCabelo0);
			criminalView.setCodigoTipoCabelo(criminalView.wTipoCabelo0);
			criminalView.setCodigoCorOlhos(criminalView.wCorOlhos0);
			criminalView.setMarcaPartCicatTatuag(scrm2300.getJsinais());
			criminalView.setCompleicao(criminalView.wCompleicao0);
			criminalView.setNomeVitima(scrm2300.getJnomevitima());
			criminalView.setMotivoPrisaoLei(scrm2300.getJmotivo());
			criminalView.setDataDocAtu(criminalView.wData_atu);
			criminalView.setHoraAtu(criminalView.wHora_atu);
			criminalView.setMatriculaFuncAtu(sessao.getScrg001().getWMatriculaw());
			criminalView.atualiza();
		}
		if (criminalView.registrosProcessados() == 0) {
			// dao.rollback();
			scrm2300.enviarMensagem(null, "Ficha Criminal nao cadastrada");
			return;
		}

		if (!scrp1200B.getEnviada()) // CONFIRMACAO
		{
			result.include("scrp1200B", scrp1200B);
			sessao.setAtributo("SCRP1200", this);
			scrp1200B.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
			return;
		}
		if (pscrp1200B != null) {
			scrp1200B.receberTela(false, result);
		}

		if (!((UtilBean.funcao.equals(UtilBean.ctt_retorna) || UtilBean.funcao.equals(UtilBean.ctt_processa)))) {
			scrp1200B.enviarMensagem(null, "Tecla invalida");
			result.include("scrp1200B", scrp1200B);
			sessao.setAtributo("SCRP1200", this);
			scrp1200B.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
			return;
		}
		if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {
			scrp1200.executar(null, null, null, null, null, null, null);
			result.include("scrp1200B", scrp1200B);
			sessao.setAtributo("SCRP1200", this);
			scrp1200B.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
			return;
		}
		if (scrp1200B.getJconf().trim().equals("")) {
			scrp1200B.enviarMensagem("jConf", "Confirme �S� ou �N�");
			result.include("scrp1200B", scrp1200B);
			sessao.setAtributo("SCRP1200", this);
			scrp1200B.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
			return;
		}
		if (!(scrp1200B.getJconf().equals("S") || scrp1200B.getJconf().equals("N"))) {
			scrp1200B.enviarMensagem("jConf", "Confirmacao invalida");
			result.include("scrp1200B", scrp1200B);
			sessao.setAtributo("SCRP1200", this);
			scrp1200B.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
			return;
		}
		if (scrp1200B.getJconf().equals("N")) {
			// dao.rollback();
			scrp1200.executar(null, null, null, null, null, null, null);
			return;
		} else {
			if (criminalView.wLoop == 1) {

				if (!scrp1200C.getEnviada()) // CONFIRMACAO
				{
					result.include("scrp1200C", scrp1200C);
					sessao.setAtributo("SCRP1200", this);
					scrp1200C.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
					return;
				}
				if (pscrp1200C != null) {
					scrp1200C.receberTela(false, result);
				}

				if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {

					// dao.rollback();
					scrp1200.setMensagem("ATUALIZACAO NAO CONFIRMADA - TECLE <ENTER>");
					scrp1200.executar(null, null, null, null, null, null, null);
					return;
				}
				if (scrp1200C.getJmat() == 0) {
					scrp1200C.enviarMensagem("jMat", "Informe a Matricula");
					result.include("scrp1200C", scrp1200C);
					sessao.setAtributo("SCRP1200", this);
					scrp1200C.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
					return;
				}
				if (scrp1200C.getJmat() != sessao.getScrg001().getWMatriculaw()) {
					scrp1200C.enviarMensagem("jMat", "Matricula nao corresponde a Matricula Inicial");
					result.include("scrp1200C", scrp1200C);
					sessao.setAtributo("SCRP1200", this);
					scrp1200C.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
					return;
				}
				if (scrp1200C.getJsenha().trim().equals("")) {
					scrp1200C.enviarMensagem("jSenha", "Informe sua Senha");
					result.include("scrp1200C", scrp1200C);
					sessao.setAtributo("SCRP1200", this);
					scrp1200C.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
					return;
				}
				if (scrp1200C.getJsenha() != sessao.getScrg001().getWSenhaw()) {
					scrm2300.enviarMensagem("jSenha", "Senha nao Corresponde a Senha Inicial");
					result.include("scrp1200C", scrp1200C);
					sessao.setAtributo("SCRP1200", this);
					scrp1200C.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
					return;
				}
				// dao.commit();

				scrm2000.enviarMensagem("", "REGISTRO ALTERADO COM SUCESSO - TECLE <ENTER>");
				// scrp1200A.enviarenviarreceber(false, result);
				dmanas = "";
				for (int i1 = 1; i1 <= 5; i1++) {
					for (int i2 = 1; i2 <= 2; i1++) {
						criminalView.dedos[i1][i2] = "";
					}
				}
				jCrime = "";
			} else {
				// dao.commit();

				scrm2000.enviarMensagem("", "REGISTRO ALTERADO COM SUCESSO - TECLE <ENTER>");
				// scrp1200A.enviarenviarreceber(false, result);
				dmanas = "";
				for (int i1 = 1; i1 <= 5; i1++) {
					for (int i2 = 1; i2 <= 2; i1++) {
						criminalView.dedos[i1][i2] = "";
					}
				}
				jCrime = "";
			}
		}
		// jVariaveis_da_tela = "";
		criminalView.wChave = "";
		criminalView.wText = "";
		jCrime = "";

		sessao.setAtributo("SCRP1200", this);
		result.include("scrm2000", scrm2000);
		scrm2000.enviarTela(primeiraVez, result, getClass().getSimpleName().toUpperCase());
	}

	private void gravaOcorrencias(Scrp1200A pscrp1200A) {
		int ind = 0;
		criminalView.wI = 5;
		if (!scrm2300.getJobservacoes(1).trim().equals("")) {
			if (!((UtilBean.funcao.equals(UtilBean.ctt_retorna) || UtilBean.funcao.equals(UtilBean.ctt_processa)))) {
				scrm2300.enviarMensagem(null, "Tecla invalida");
				return;
			}
			criminalView.wObservacoez[1] = scrm2300.getJobservacoes(1);
			criminalView.wObservacoez[2] = scrm2300.getJobservacoes(2);
			criminalView.wObservacoez[3] = scrm2300.getJobservacoes(3);
			criminalView.wObservacoez[4] = scrm2300.getJobservacoes(4);
		}

		for (ind = 2; ind <= 40; ind++) {
			scrm2300.setJocorrencia(ind);
			if (scrm2300.getJocorrencia() == 2) {
				criminalView.wJ = scrm2300.getJocorrencia() + 4;
				criminalView.wL = scrm2300.getJocorrencia() + 5;
				criminalView.wM = scrm2300.getJocorrencia() + 6;
			} else {
				criminalView.wI = criminalView.wM + 1;
				criminalView.wJ = criminalView.wM + 2;
				criminalView.wL = criminalView.wM + 3;
				criminalView.wM = criminalView.wM + 4;
			}

			scrm2300.setJobservacoes(1, criminalView.wObservacoez[criminalView.wI]);
			scrm2300.setJobservacoes(2, criminalView.wObservacoez[criminalView.wJ]);
			scrm2300.setJobservacoes(3, criminalView.wObservacoez[criminalView.wL]);
			scrm2300.setJobservacoes(4, criminalView.wObservacoez[criminalView.wM]);

			if (!scrp1200A.getEnviada()) // CONFIRMACAO
			{
				result.include("scrp1200A", scrp1200A);
				sessao.setAtributo("SCRP1200", this);
				scrp1200A.enviarTela(false, result, getClass().getSimpleName().toUpperCase());
				return;
			}
			if (pscrp1200A != null) {
				scrp1200A.receberTela(false, result);
			}

			//
			if (!((UtilBean.funcao.equals(UtilBean.ctt_retorna) || UtilBean.funcao.equals(UtilBean.ctt_processa)))) {
				scrm2300.enviarMensagem(null, "Tecla invalida");
				return;
			}

			if (UtilBean.funcao.equals(UtilBean.ctt_retorna)) {
				scrp1200.executar(null, null, null, null, null, null, null);
				return;
			}
			// IF #OBSERVACOES(1) = ' '
			// ESCAPE BOTTOM
			// END-IF
			criminalView.wObservacoez[criminalView.wI] = scrm2300.getJobservacoes(1);
			criminalView.wObservacoez[criminalView.wJ] = scrm2300.getJobservacoes(2);
			criminalView.wObservacoez[criminalView.wL] = scrm2300.getJobservacoes(3);
			criminalView.wObservacoez[criminalView.wM] = scrm2300.getJobservacoes(4);

			// RESET #OBSERVACOES(*)
			for (criminalView.wX = 4; criminalView.wX >= 2; criminalView.wX += -1) {
				if (!scrm2300.getJobservacoes(criminalView.wX).trim().equals("")) {
					criminalView.wW = criminalView.wX - 1;
					for (criminalView.wY = criminalView.wW; criminalView.wY >= 1; criminalView.wY += -1) {
						if (scrm2300.getJobservacoes(criminalView.wY).trim().equals("")) {
							scrm2300.enviarMensagem(null, "");
							return;
						}
					}
				}
			}
		}
		if (scrm2300.getJobservacoes(1).trim().equals("")) {
			return;
		}

	}

	// END-IF
	private void verStatus() {
		switch (criminalView.wStatus0) {
		case 0: {
			criminalView.wDescreg = "Registro Normal";
			break;
		}
		case 1: {
			criminalView.wDescreg = "Registro Cancelado";
			break;
		}
		case 2: {
			criminalView.wDescreg = "Registro com Mandato de Prisao preventiva";
			break;
		}
		case 3: {
			criminalView.wDescreg = "Condenado";
			break;
		}
		default: {
			break;
		}
		}
	}

	private void restaurarEstados(Scrm2000 pscrm2000, Scrm2100 pscrm2100, Scrm2200 pscrm2200, Scrm2300 pscrm2300, Scrp1200A pscrp1200A, Scrp1200B pscrp1200B, Scrp1200C pscrp1200C) {
		this.scrp1200Anterior = (Scrp1200) sessao.getAtributo("SCRP1200");
		if (pscrm2000 != null) {
			scrm2000 = pscrm2000;
		} else {
			scrm2000 = this.scrp1200Anterior.scrm2000;
		}
		scrm2000.setSessao(sessao);
		if (pscrm2100 != null) {
			scrm2100 = pscrm2100;
		} else {
			scrm2100 = this.scrp1200Anterior.scrm2100;
		}
		scrm2100.setSessao(sessao);
		if (pscrm2200 != null) {
			scrm2200 = pscrm2200;
		} else {
			scrm2200 = this.scrp1200Anterior.scrm2200;
		}
		if (pscrm2300 != null) {
			scrm2300 = pscrm2300;
		} else {
			scrm2300 = this.scrp1200Anterior.scrm2300;
		}
		scrm2300.setSessao(sessao);
		if (pscrp1200A != null) {
			scrp1200A = pscrp1200A;
		} else {
			scrp1200A = this.scrp1200Anterior.scrp1200A;
		}
		scrp1200A.setSessao(sessao);
		if (pscrp1200B != null) {
			scrp1200B = pscrp1200B;
		} else {
			scrp1200B = this.scrp1200Anterior.scrp1200B;
		}
		scrp1200B.setSessao(sessao);
		if (pscrp1200C != null) {
			scrp1200C = pscrp1200C;
		} else {
			scrp1200C = this.scrp1200Anterior.scrp1200C;
		}
		scrp1200C.setSessao(sessao);
		this.faseproc = this.scrp1200Anterior.faseproc;
	}

	protected void setMensagem(String mensagem) {
		mensagemInicial = mensagem;
	}
}
